package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateFaceApplyInfoDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateFaceApplyInfoGetPageDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateUserFaceInfoPageDTO;
import com.itlong.cloud.POJO.VO.operate.OperateFaceApplyInfoVO;
import com.itlong.cloud.POJO.VO.operate.OperateUserFaceInfoVO;
import com.itlong.cloud.operate.service.IOperateFaceApplyService;
import com.itlong.cloud.project.operate.IOperateFaceApplyServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <desc>
 *   运营-人脸管理-应用管理接口暴露实现。
 * <desc/>
 *
 * @createDate 2018-05-03.
 */
@RestController
public class OperateFaceApplyServiceResource implements IOperateFaceApplyServiceClient {

    @Autowired
    IOperateFaceApplyService iOperateFaceApplyService;
    /**
     * <desc>
     *      保存人脸应用信息。
     * <desc/>
     *
     * @param  saveDTO 人脸应用信息对象
     * @return
     * @author shengen.T
     * @createDate 2018-05-03
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/save", method = {RequestMethod.POST})
    public Map<String,Object> saveFaceApplyInfo(@RequestBody OperateFaceApplyInfoDTO saveDTO) throws Exception{
        return iOperateFaceApplyService.saveFaceApplyInfo(saveDTO);
    }


    /**
     * <desc>
     *      更新人脸应用信息。
     * <desc/>
     *
     * @param  applyName 应用名称
     * @param  remark  备注
     * @return
     * @author shengen.T
     * @createDate 2018-05-04
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/update", method = {RequestMethod.POST})
    public Integer updateFaceApplyInfo(@RequestParam("applyName") String applyName, @RequestParam("remark") String remark,@RequestParam("appId") String appId,@RequestParam("id") Integer id) throws Exception{
        return iOperateFaceApplyService.updateFaceApplyInfo(applyName,remark,appId,id);
    }

    /**
     * <desc>
     *      检测appid是否跟项目绑定了。
     * <desc/>
     *
     * @param appId
     * @return
     * @author shengen.T
     * @createDate 2018-05-04
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/checkAppIdIsUse", method = {RequestMethod.POST})
    public Integer checkAppIdIsUse(@RequestParam("appId") String appId) throws Exception{
        return iOperateFaceApplyService.checkAppIdIsUse(appId);
    }

    /**
     * <desc>
     *      删除人脸应用信息。
     * <desc/>
     *
     * @param  appId 编号
     * @return
     * @author shengen.T
     * @createDate 2018-05-04
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/delete", method = {RequestMethod.POST})
    public Integer deleteFaceApplyInfo(@RequestParam("appId") String appId,@RequestParam("id") Integer id) throws Exception{
        return iOperateFaceApplyService.deleteFaceApplyInfo(appId,id);
    }

    /**
     * <desc>
     *      获取单个应用信息。
     * <desc/>
     *
     * @param  appId
     * @return
     * @author shengen.T
     * @createDate 2018-05-04
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/getOne", method = {RequestMethod.POST})
    public OperateFaceApplyInfoVO getOneInfo(@RequestParam("appId") String appId,@RequestParam("id") Integer id) throws Exception{
        return iOperateFaceApplyService.getOneInfo(appId,id);
    }

    /**
     * <desc>
     *      分页获取人脸数据。
     * <desc/>
     *
     * @param  pageDTO
     * @return
     * @author shengen.T
     * @createDate 2018-05-07
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/getPage", method = {RequestMethod.POST})
    public Page<OperateFaceApplyInfoVO> getPageInfo(@RequestBody OperateFaceApplyInfoGetPageDTO pageDTO) throws Exception{
        return iOperateFaceApplyService.getPageInfo(pageDTO);
    }

    /**
     * <desc>
     *      分页获取人脸库信息。
     * <desc/>
     *
     * @param  pageDTO 人脸用户查询对象
     * @return
     * @author shengen.T
     * @createDate 2018-05-07
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/getFacePage", method = {RequestMethod.POST})
    public Page<OperateUserFaceInfoVO> getFacePage(@RequestBody OperateUserFaceInfoPageDTO pageDTO) throws Exception{
        return iOperateFaceApplyService.getFacePage(pageDTO);
    }

    /**
     * <desc>
     *      获取指定项目人脸库信息(人脸认证权限)。
     * <desc/>
     *
     * @param  projectId 项目编号
     * @return
     * @author Qiang.S
     * @createDate 2018-05-22
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/getFaceByProjectId", method = {RequestMethod.POST})
    public OperateFaceApplyInfoVO getFaceByProjectId(@RequestParam(value = "projectId",required = false) String projectId) throws Exception{
        return iOperateFaceApplyService.getFaceByProjectId(projectId);
    }

    /**
     * <desc>
     *      获取指定项目人脸库信息(云电梯)。
     * <desc/>
     *
     * @param  projectId 项目编号
     * @return
     * @author Qiang.S
     * @createDate 2018-06-08
     */
    @Override
    @RequestMapping(path = "/operate/face/applyManage/getElevatorFaceByProjectId", method = {RequestMethod.POST})
    public OperateFaceApplyInfoVO getElevatorFaceByProjectId(@RequestParam("projectId") String projectId) throws Exception{
        return iOperateFaceApplyService.getElevatorFaceByProjectId(projectId);
    }
}
